var t = getApp();

Page({
    data: {
        showDate: "",
        startMonth: "",
        endMonth: "",
        teamId: "",
        rankData: [],
        date: ""
    },
    loadData: function() {
        var a = this;
        t.network.post({
            url: t.url.listScheduleRank,
            params: {
                teamId: a.data.teamId,
                startMonth: a.data.startMonth,
                endMonth: a.data.endMonth
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(e) {
                1 == e.data.result ? (console.log(e.data.data.scheduleRanks), a.setData({
                    rankData: e.data.data.scheduleRanks
                })) : t.util.showToast(e.data.message);
            },
            fail: function() {
                t.util.showToast("获取信息失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    clickNextMonth: function(t) {
        var a = new Date(this.data.date), e = a.getFullYear(), n = a.getMonth() + 1 + 1;
        n < 10 ? n = "0" + n : n > 12 && (n = "01", e += 1);
        var o = e + "-" + n, s = e + "年" + n + "月";
        this.setData({
            showDate: s,
            startMonth: o,
            endMonth: o,
            date: o
        }), this.loadData();
    },
    clickLastMonth: function(t) {
        var a = new Date(this.data.date), e = a.getFullYear(), n = a.getMonth();
        0 == n ? (n = "12", e -= 1) : n < 10 && (n = "0" + n);
        var o = e + "-" + n, s = e + "年" + n + "月";
        this.setData({
            showDate: s,
            startMonth: o,
            endMonth: o,
            date: o
        }), this.loadData();
    },
    clickThisYear: function(t) {
        var a = new Date().getFullYear(), e = a + "-01", n = a + "年";
        this.setData({
            showDate: n,
            startMonth: a + "-01",
            endMonth: a + "-12",
            date: e
        }), this.loadData();
    },
    clickLastYear: function(t) {
        var a = new Date().getFullYear() - 1, e = a + "-12", n = a + "年";
        this.setData({
            showDate: n,
            startMonth: a + "-01",
            endMonth: a + "-12",
            date: e
        }), this.loadData();
    },
    bindDateChange: function(t) {
        console.log("picker发送选择改变，携带值为", t.detail.value);
        var a = new Date(t.detail.value), e = a.getFullYear(), n = a.getMonth() + 1;
        n < 10 && (n = "0" + n);
        var o = e + "-" + n, s = e + "年" + n + "月";
        this.setData({
            showDate: s,
            startMonth: o,
            endMonth: o,
            date: o
        }), this.loadData();
    },
    onLoad: function(t) {
        var a = t.teamId, e = new Date(), n = e.getFullYear(), o = e.getMonth() + 1;
        o < 10 && (o = "0" + o);
        var s = n + "-" + o, h = n + "年" + o + "月";
        this.setData({
            showDate: h,
            endMonth: s,
            startMonth: s,
            teamId: a,
            date: s
        }), this.loadData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});